//
//  SDEvaluateModel.m
//  FD
//
//  Created by xiaofang wang on 2018/11/15.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.
//

#import "SDEvaluateModel.h"

@implementation SDEvaluateModel

- (void)setUser:(NSDictionary *)user {
    _user = user;
    
    self.head = [NSString stringWithFormat:@"%@%@",kPicDomain,user[@"head"]]; //头像
    self.nickname = user[@"nickname"]; //昵称
}

- (CGFloat)cellHeight {
    
    //已经计算过了就直接返回
    if(_cellHeight) return _cellHeight;
    
    //
    _cellHeight = 60; //div1(头像+昵称+评星+xx) 固定高度45
    
    //文字高度:定宽才能算出高度
    CGFloat textMaxW = [UIScreen mainScreen].bounds.size.width - 60 - 10;
    CGSize textMaxSize = CGSizeMake(textMaxW, MAXFLOAT);
    CGSize textSize = [self.content boundingRectWithSize:textMaxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:20]} context:nil].size;
    FDLog(@"%@",NSStringFromCGSize(textSize));
    
    if (textSize.height < 30) {
        _cellHeight += 40;
    }else {
        _cellHeight += textSize.height;
    }
    
    _cellHeight += 15; //间距: 10+5
    if (self.thumbnail.count) { //有图片
        _cellHeight += 70 + 5; //加上图片的高度。 + 5个间距
    }
    
    //返回
    return _cellHeight;
}
@end
